#pragma once

#include "TSSrv_i.h"
#include "ConfigMgr.h"



class CDBHelper
{
public:
	CDBHelper(BSTR productName)
	{
		m_ProductName = productName;
	}

	HRESULT Connect();
	
	HRESULT Close();
	BOOL IsConnected();
	HRESULT ExecuteText(BSTR sql, ADODB::_RecordsetPtr &spRecSet);
	HRESULT GetCommand(ADODB::_CommandPtr& spCmd);
	_bstr_t GetProductName()
	{
		return m_ProductName;
	}

public:
    
	//HRESULT ExecuteText(BSTR sql,IResultSet** ppResultSet);

private:
	ADODB::_ConnectionPtr m_spConn;
	_bstr_t m_tsConnString;
	_bstr_t m_ProductName;
	//static list m_ConnectPool 

public:
    HRESULT GetDataItem(TsDatastoreItemTypeEnum datastoreItemType, INT id, ADODB::_RecordsetPtr& spRS);
	//_bstr_t GetTSConnectionString(void);
	static _bstr_t GetConnectionString(_bstr_t prodctName);
	static HRESULT GetConnectingStrings(CComSafeArray<BSTR>& safeArray);
	//HRESULT GetDatastoreItem(TsDatastoreItemTypeEnum itemType, int id, IDatastoreItem** ppDatastoreItem);
};